home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Debugging OpenDoc / Debugging Documentation / …Using Jasik's Debugger < prev    next >
Encoding:
Text File  |  1995-07-06  |  4.6 KB  |  66 lines  |  [TEXT/ttxt]

  1. Jasik Debugger Tech Note #12
  2.  
  3. Opendoc & CFM Library Debugging
  4.  
  5. This tech note discusses the how and why of debugging Code Fragment Manager (CFM) Libraries .  Most OpenDoc parts are CFM Libraries, but I put it in the title to catch your attention.  As of this writing The Debugger does not handle CFM 68K Libraries, and when  possible you should debug native versions of the CFM Libraries or OpenDoc parts you are building.
  6.  
  7. Background
  8. As you know, The Debugger lurks in the background and looks for the loading of interesting objects, such as executable resources and Applications.  To do this, it patches the various flavors of the _GetResource trap and _LoadSeg.  In the case of objects loaded by CFM, it installs a ‘notify’ proc which is called by CFM when Libraries are loaded, unloaded, etc.  This enables The Debugger to monitor what is happening and load the appropriate ‘sym’ files just after a library is loaded.
  9.  
  10. NOTE: when I say ‘sym’ file I am referring to a file containing symbol info for a program that is formatted according to an Apple specification.  Files containing information for 68K programs are suffixed with ‘.sym’ and those for PowerPC programs are suffixed with ‘.xSYM’.
  11.  
  12. In the case of 68K Applications, TD looks for a ‘sym’ file with the name AppName.sym
  13. and PPC, ‘AppName.xsym’.  To debug 68K resources, one names the ‘sym’ file as:
  14.  ‘RsrcFileName/rrrr_nnn.sym’  where rrrr is the resource type (case sensitive) and nnn is the resource id in hex with no leading zeros.
  15.  
  16. For CFM libraries, the basic convention is that TD looks for the symbol info in a file named ‘LibraryName.xSYM’ in the same folder as the Library.
  17. In addition, when an Application or Library is loaded,  TD also looks at all the other CFM Libraries that are Linked in (in the ‘closure’), and if they have ‘sym’ files, then they are also loaded.  If the flag DBG_SLM is OFF, then TD will NOT look for the ‘sym’ files of disk based libraries.
  18. To debug native (Accelerated) code resources, the flag: DBG_RSRCs must be ON
  19. and the ‘sym’ or Aux file name is ‘LibraryName.xSYM’.  You may also have to set the
  20. ‘=Generic’ resource type if the resource type you are loading is not one of the standard
  21. types I recognize
  22.  
  23. Note:  The name of a library is dynamically assigned by CFM when the library is loaded.
  24.   The Library name is passed as the 3rd argument to GetDiskFragment or GetMemFragment.
  25.   This has confused many of you in the past.  If you don’t give the Library a name, then
  26.   it will show up as <-> in the list of loaded libraries.
  27.  
  28. Facilities
  29. There are a variety of ways in which you can associate a ‘sym’ file with a loaded CFM library.
  30.  
  31. Manual
  32. You can use the Target Library command in the Tables Menu.  The first time you bring it up, it will display the list of loaded libraries and ask you to select a Library.  After you have hilited a library name, select the command a second time and it will put up a SF Getfile dialog and you are expected to select the ‘.xSYM’ file.
  33. Remember that the reason it shows you the whole list of libraries, is that when you select one, you are also selecting the ‘data section’ associated with that invocation of the library.
  34.  
  35. Semi-Automatic
  36. You can automate the above process by hiliting (.dsi file) lines of the form:
  37.  
  38. =L
  39. LibraryName    (case Sensitive)
  40. path:Filename.xSYM
  41.  
  42. and doing a Ω-F  (Execute Selection) command.
  43. You may NOT execute such lines as part of a ‘.dsi’ file associated with an Application, ...
  44. as it will cause recursive re-entry to the ‘add task’ processor in The Debugger.
  45.  
  46. An example of adding the symbol info for 2 libraries is:
  47.  
  48. (=L
  49. Lib_A
  50. myDisk: .... :Lib_A.xSYM
  51. =L
  52. Lib_B
  53. myDisk: .... :Lib_B.xSYM)
  54.  
  55. One can hilite the lines by clicking on the opening paren and Ω-F
  56.  
  57. Automatic
  58. If DBG_SLM is ON, then TD will automatically look for and process the ‘sym’ info of libraries as they are loaded.  If you are debugging native code resources, then you will also have to turn the DBG_RSRCs flag on, and possibly set the =Generic Code resource type to that of the resource holding the accelerated resource.  In both cases, the sym file name is ‘Libname.xSYM’.
  59.  
  60. Some Strategies
  61. Some of you who are debugging Applications or such with a large number of associated libraries have complained to me about the amount of time it takes to load the symbol info for the libraries.  Some alternatives are:
  62. 1) Rename the ‘sym’ files of the libraries you are not interested in debugging so that TD
  63.     doesn’t pick them up automatically.  If you need them, use the next strategy.
  64. 2) Turn DBG_SLM OFF and load the ‘sym’ info for the libraries as you need them (after a crash, …)     via the ‘semi-automatic’ method.
  65.      Remember to execute a ‘stack crawl’ command after you load the libraries.
  66.